import React, { useEffect, useState } from 'react'
import PubNav from '../../components/publicComponents/pubNav'
import { useLocation, useNavigate } from 'react-router-dom'
import style from './index.module.css'

export default function Store() {
  const location = useLocation()
  const navigate = useNavigate()
  let [userId, setUserId] = useState('')
  let [goodsId, setGoodsId] = useState<number>()
  let [storeId, setStoreId] = useState<number>()

  useEffect(() => {
    const id = localStorage.getItem('userId')
    const curState = location.state as {
      goodsId: number
      storeId: number
    }
    // goodsId = curState.goodsId
    // storeId = curState.storeId
    // setGoodsId(curState.goodsId)
    // setStoreId(curState.storeId)
    if (id) {
      userId = id
      setUserId(id)
    } else {
      navigate('/login')
    }
    console.log(goodsId, storeId)
  }, [])

  return (
    <div style={{ paddingTop: '46px' }}>
      <PubNav title="欢迎光临小店" />
      <div className={style['store-container']}>
        {/* <div className={style['store-info']}>
          <div className={style['head']}>
            <img src={storeData?.storeAvatar} alt="" />
          </div>
          <div className={style['store-detail']}>
            <div className={style['store-title']}>{storeData?.storeName}</div>
            <div className={style['store-content']}>
              <div className={style['address']}>
                <div className={style['address-icon']}>
                  <img src="/static/use/icon-addres-9e9.png" alt="" />
                </div>
                <div>{storeData?.area}</div>
              </div>
              <div className={style['distance']}>距您{storeData?.distance}km</div>
              <div>车程{storeData?.time}分钟</div>
            </div>
          </div>
          <div
            className={style['enter-store']}
            onClick={() => {
              navigate('/store?storeid=' + storeId, {
                state: {
                  storeId,
                  goodsId
                }
              })
            }}
          >
            进店
          </div>
        </div> */}
      </div>
    </div>
  )
}
